
/*
 * Copyright 2002-2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2012原作者。
 *
 *根据Apache许可证2.0版（“许可证”）许可；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，否则软件
 *根据许可证分发是在“按原样”的基础上分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证
 *许可证下的限制。
 */

package org.springframework.context;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.Aware;

/**
 * Interface to be implemented by any object that wishes to be notified
 * of the {@link ApplicationContext} that it runs in.
 *
 * <p>Implementing this interface makes sense for example when an object
 * requires access to a set of collaborating beans. Note that configuration
 * via bean references is preferable to implementing this interface just
 * for bean lookup purposes.
 *
 * <p>This interface can also be implemented if an object needs access to file
 * resources, i.e. wants to call {@code getResource}, wants to publish
 * an application event, or requires access to the MessageSource. However,
 * it is preferable to implement the more specific {@link ResourceLoaderAware},
 * {@link ApplicationEventPublisherAware} or {@link MessageSourceAware} interface
 * in such a specific scenario.
 *
 * <p>Note that file resource dependencies can also be exposed as bean properties
 * of type {@link org.springframework.core.io.Resource}, populated via Strings
 * with automatic type conversion by the bean factory. This removes the need
 * for implementing any callback interface just for the purpose of accessing
 * a specific file resource.
 *
 * <p>{@link org.springframework.context.support.ApplicationObjectSupport} is a
 * convenience base class for application objects, implementing this interface.
 *
 * <p>For a list of all bean lifecycle methods, see the
 * {@link org.springframework.beans.factory.BeanFactory BeanFactory javadocs}.
 *
 * @author Rod Johnson
 * @author Juergen Hoeller
 * @author Chris Beams
 * @see ResourceLoaderAware
 * @see ApplicationEventPublisherAware
 * @see MessageSourceAware
 * @see org.springframework.context.support.ApplicationObjectSupport
 * @see org.springframework.beans.factory.BeanFactoryAware
 */
/**
 *要由任何希望被通知的对象实现的接口
 *它在其中运行的｛@link ApplicationContext｝的。
 *
 *＜p＞实现这个接口是有意义的，例如当一个对象
 *需要访问一组协作bean。请注意，配置
 *通过bean引用比只实现这个接口更可取
 *用于bean查找目的。
 *
 *<p>如果对象需要访问文件，也可以实现此接口
 *resources，即想要调用｛@code getResource｝，想要发布
 *应用程序事件，或需要访问MessageSource。然而
 *优选实现更具体的{@link ResourceLoaderAware}，
 *｛@link ApplicationEventPublisherware｝或｛@linkMessageSourceAware｝接口
 *在这样一个特定的场景中。
 *
 *<p>注意，文件资源依赖性也可以作为bean财产公开
 *类型为{@linkorg.springframework.core.io.Resource}，通过字符串填充
 *通过豆工厂进行自动类型转换。这就消除了需求
 *用于实现任何回调接口，仅用于访问
 *特定的文件资源。
 *
 *＜p＞｛@link org.springframework.context.support.ApplicationObjectSupport｝是一个
 *应用程序对象的便利基类，实现这个接口。
 *
 *＜p＞有关所有bean生命周期方法的列表，请参阅
 *｛@link org.springframework.beans.factory.BeanFactory BeanFactory javadocs｝。
 *
 *@作者罗德·约翰逊
 *@作者Juergen Hoeller
 *@作者Chris Beams
 *@请参阅ResourceLoaderAware
 *@请参阅ApplicationEventPublisherware
 *@请参阅MessageSourceAware
 *@请参阅org.springframework.context.support.ApplicationObjectSupport
 *@参见org.springframework.beans.factory.BeanFactoryAware
 */
public interface ApplicationContextAware extends Aware {

	/**
	 * Set the ApplicationContext that this object runs in.
	 * Normally this call will be used to initialize the object.
	 * <p>Invoked after population of normal bean properties but before an init callback such
	 * as {@link org.springframework.beans.factory.InitializingBean#afterPropertiesSet()}
	 * or a custom init-method. Invoked after {@link ResourceLoaderAware#setResourceLoader},
	 * {@link ApplicationEventPublisherAware#setApplicationEventPublisher} and
	 * {@link MessageSourceAware}, if applicable.
	 * @param applicationContext the ApplicationContext object to be used by this object
	 * @throws ApplicationContextException in case of context initialization errors
	 * @throws BeansException if thrown by application context methods
	 * @see org.springframework.beans.factory.BeanInitializationException
	 */
	/**
	 *设置此对象运行的ApplicationContext。
	 *通常情况下，此调用将用于初始化对象。
	 *<p>在填充普通bean财产之后但在init回调之前调用
	 *作为{@linkorg.springframework.beans.factory.InitializingBean#afterPropertiesSet（）}
	 *或自定义init方法。在{@link ResourceLoaderAware#setResourceLoader}之后调用，
	 *｛@link ApplicationEventPublisherware#setApplicationEventPublisher｝和
	 *｛@link MessageSourceAware｝，如果适用。
	 *@param applicationContext此对象要使用的applicationContext对象
	 *在上下文初始化错误的情况下@throws ApplicationContextException
	 *@throws BeansException如果由应用程序上下文方法引发
	 *@参见org.springframework.beans.factory.BeanInitializationException
	 */
	void setApplicationContext(ApplicationContext applicationContext) throws BeansException;

}
